/*
 *============================================================================
 * Name        : project.cpp
 * Author      : suren,karthik
 * Copyright   : GPL 3.0
 * Title 	   : Optimal Power Flow using Particle Swarm Optimisation.
 * Description :
 * The code takes input about a power system from an input file.
 * Then generated N particles each with a feasible solution
 *
 * By feasible solution we mean that, we assume values for the independent
 * variables and then generate the dependent variable using fast decoupled
 * Newton-Raphson method.
 *
 * Now that we a population of particles, we move the particle in the
 * multi-dimensional space and then try to find the point at which a particle
 * can attain a minimum value for a given objective function
 *
 * ===========================================================================
 */

#include <iostream>
#include <string>
#include <vector>
#include <ctime>
#include <algorithm>
#include <fstream>

#include "pso.h"
#include "powersys.h"
#include "utilities.h"
using namespace std;

/*
 * @main() : The main function call
 *	The algorithm for the project is being described here.
 *	1. First get the input
 *	2. next generate the random independent input
 *	3. Now use Newton-Raphson method to find out the total X vector ie the set of independent and
 *	   the dependent variables.
 *	4. Initialize Particles and then call the PSO algorithm on it
 */

int main() {

  //set the input bus file and the objective here
  string bus_file = "ieee30bus.txt";
  int objective = ECONOMIC_LOAD_DISPATCH;

  // @dimensions - find out the rank of the independent vector to be optimised
  int dimensions = 0;

  //Initialize GlobalParams
  struct psoParameters globals(dimensions,objective);

  // Get the input for the bus from here !
  vector<struct bus> Buses;
  vector<struct branch> Branches;



  // Populate the swarm with the number of particles specified in the global parameters
  vector<struct Particle> Particles;
  for( int i=0; i<globals.particles; ++i){
    vector<double> initialVector = constructRandomVector(Buses,Branches,i);
    Particles.push_back(Particle(initialVector,objective));
  }


  return 0;
}
